package org.zk.dubbo_consumer.controller;


import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.zk.entity.Study;
import org.zk.service.StudyService;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Alicelonely
 * @since 2019-12-11
 */
@Controller
@RequestMapping("/study")
public class StudyController {

    @Resource
    private StudyService studyService;

    @ResponseBody
    @RequestMapping("/toStudy")
    public ModelAndView toStudy() {
        ModelAndView mv= new ModelAndView("person/kecheng");
        return mv;
    }
//
//    @RequestMapping("list")
//    public String getAllStudy(Model model){
//        List<Study> list=studyService.getAllStudy();
//        model.addAttribute("list",list);
//        return "/user/studyCour";
//    }

//    @ResponseBody
    @RequestMapping("/getAllStudy")
    public ModelAndView getAllStudy(HttpSession session){
//        return studyService.getAllStudy();
        List<Study> list=studyService.getAllStudy();
        ModelAndView mv=new ModelAndView("person/kecheng");
        mv.addObject("list",list);

       return mv;
    }



}

